package com.claimSettlement.controller;

import com.claimSettlement.pojo.SurveyLoss;
import com.claimSettlement.service.SurveyLossService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 查勘与定损控制层
 * 曹文韬 -- 2021-05-20
 */
@RestController
@RequestMapping("/surveyLoss")
public class SurveyLossController {
    @Resource
    SurveyLossService surveyLossService;

    @RequestMapping("/getSurveyLossIdOrCarframeId")
    public PageInfo<SurveyLoss> getSurveyLossIdOrCarframeId(int id, String carframeId,int page){
        PageHelper.startPage(page,4);
        List<SurveyLoss> list = surveyLossService.getSurveyLossIdOrCarframeId(id, carframeId);
        PageInfo<SurveyLoss> pageInfo = new PageInfo<SurveyLoss>(list);
        return pageInfo;
    }

    @RequestMapping(value = "/insSurveyLoss", method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
    public String insSurveyLoss(@RequestBody SurveyLoss surveyLoss){
        return surveyLossService.insSurveyLoss(surveyLoss) > 0 ? "成功":"失败";
    }

    @RequestMapping(value = "/delSurveyLoss",produces = "text/html;charset=UTF-8")
    public String delSurveyLoss(String caseId){
        return surveyLossService.delSurveyLoss(caseId) > 0 ? "成功":"失败";
    }

    @RequestMapping(value = "/updSurveyLossProspectState", method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
    public String updSurveyLossProspectState(@RequestBody SurveyLoss surveyLoss){
        return surveyLossService.updSurveyLossProspectState(surveyLoss) > 0 ? "成功":"失败";
    }

    @RequestMapping(value = "/updSurveyLossSettUserId", method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
    public String updSurveyLossSettUserId(@RequestBody SurveyLoss surveyLoss){
        return surveyLossService.updSurveyLossSettUserId(surveyLoss) > 0 ? "成功":"失败";
    }
}
